'use strict';

const dayjs = require('dayjs');
const Subscription = require('egg').Subscription;

// YZX 腾讯视频 每个月最后一天晚上8点
class DailyTaskJhshCache extends Subscription {
  static get schedule() {
    return {
      // interval: '5s',
      type: 'worker',
      cron: `0 0 20 * * *`,
    };
  }
  async base_subscribe({ name, content }) {
    await this.service.mailer.send({
      emails: ['2428047022@qq.com'],
      subject: `定时提醒-${name}`,
      html: content,
    });
  }
  async subscribe() {
    if (dayjs().month() === dayjs().daysInMonth()) {
      await this.base_subscribe({
        name: '腾讯视频提醒',
        content: '腾讯视频签到',
      });
    }
  }
}

module.exports = DailyTaskJhshCache;
